<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>气泡卡片 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/popover/popover.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 气泡卡片</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>💬 气泡卡片演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item">
                        <h3>上方气泡</h3>
                        <button id="topButton" class="btn btn-primary">悬停查看</button>
                    </div>

                    <div class="demo-item">
                        <h3>下方气泡</h3>
                        <button id="bottomButton" class="btn btn-primary">悬停查看</button>
                    </div>

                    <div class="demo-item">
                        <h3>左方气泡</h3>
                        <button id="leftButton" class="btn btn-primary">悬停查看</button>
                    </div>

                    <div class="demo-item">
                        <h3>右方气泡</h3>
                        <button id="rightButton" class="btn btn-primary">悬停查看</button>
                    </div>

                    <div class="demo-item">
                        <h3>带标题的气泡</h3>
                        <button id="titleButton" class="btn btn-primary">悬停查看</button>
                    </div>

                    <div class="demo-item">
                        <h3>点击触发</h3>
                        <button id="clickButton" class="btn btn-primary">点击查看</button>
                    </div>

                    <div class="demo-item">
                        <h3>无箭头气泡</h3>
                        <button id="noArrowButton" class="btn btn-primary">悬停查看</button>
                    </div>

                    <div class="demo-item">
                        <h3>自定义宽度</h3>
                        <button id="customWidthButton" class="btn btn-primary">悬停查看</button>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/popover/popover.css"&gt;
&lt;script src="components/popover/popover.js"&lt;/script&gt;

// 2. 创建触发元素
&lt;button id="triggerButton"&gt;悬停查看&lt;/button&gt;

// 3. 初始化气泡卡片
const popover = new Popover({
    trigger: '#triggerButton',
    title: '标题',
    content: '这是气泡卡片内容',
    placement: 'top',
    trigger_type: 'hover',
    onShow: () => {
        console.log('气泡已显示');
    },
    onHide: () => {
        console.log('气泡已隐藏');
    }
});

// 4. 显示气泡
popover.show();

// 5. 隐藏气泡
popover.hide();</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/popover/popover.js"></script>
    <script>
        // 上方气泡
        new Popover({
            trigger: '#topButton',
            content: '这是一个上方气泡卡片',
            placement: 'top'
        });

        // 下方气泡
        new Popover({
            trigger: '#bottomButton',
            content: '这是一个下方气泡卡片',
            placement: 'bottom'
        });

        // 左方气泡
        new Popover({
            trigger: '#leftButton',
            content: '这是一个左方气泡卡片',
            placement: 'left'
        });

        // 右方气泡
        new Popover({
            trigger: '#rightButton',
            content: '这是一个右方气泡卡片',
            placement: 'right'
        });

        // 带标题的气泡
        new Popover({
            trigger: '#titleButton',
            title: '提示',
            content: '这是一个带标题的气泡卡片',
            placement: 'top'
        });

        // 点击触发
        new Popover({
            trigger: '#clickButton',
            content: '这是一个点击触发的气泡卡片',
            placement: 'top',
            trigger_type: 'click'
        });

        // 无箭头气泡
        new Popover({
            trigger: '#noArrowButton',
            content: '这是一个无箭头的气泡卡片',
            placement: 'top',
            showArrow: false
        });

        // 自定义宽度
        new Popover({
            trigger: '#customWidthButton',
            content: '这是一个宽度为 300px 的气泡卡片。可以包含更多内容。',
            placement: 'top',
            width: '300px'
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100px;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 14px;
            color: var(--text-primary);
            width: 100%;
            text-align: center;
        }

        .btn {
            padding: 8px 16px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 13px;
            transition: var(--transition);
        }

        .btn-primary {
            background: var(--primary-color);
            color: white;
        }

        .btn-primary:hover {
            opacity: 0.9;
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            }
        }
    </style>
</body>
</html>
